<?php
if(!defined('ADMINPX') || !defined('ADMIN')) {
	exit('Access Denied');
}
$act=$_GET['act'];
$uid=$_GET['uid'];
$id=$_GET['id'];
$aa=$_GET['aa'];
if($act =='xg'){
$row=$db->get_one('url'," `id` ='$id'",'');
if($row[type] == '1'){$a='CHECKED';}else{$aa='CHECKED';}
echo <<<end
<div class="admin">修改域名<br/></div>
<form method="POST" action="admin.php?action=url&act=ok&id=$row[id]">
<b>设置</b>:
<input type="radio" $a name="type" value="1" />开启
<input type="radio" $aa name="type" value="0" />关闭
</br>
<b>域名</b>:<input class="text" type="text" name="url" value="$row[url]" /></br>
<b>地址</b>:<input class="text" type="text" name="content" value="$row[content]" /></br>
<input class="submit" type="submit" name="adminpost" value="编辑资料"/>
<a href="admin.php?action=url&act=sc&id=$row[id]">删除域名</a><br/>
</form>
<div class="admin_a">注意: 请先把你的域名绑定到ip:<font color="ff0000">$serverip</font> 上，然后设置绑定的地址。<br/></div>
end;
echo "<a href=\"admin.php?action=url&\">返回域名管理</a><br/>";
}else if($act =='ok'){
		 if(!$_POST[adminpost]){
	      echo"提交出错<br/>";
	  }elseif($db->update('url',array('type' => $_POST[type] ,'url' => $_POST[url] ,'content' => $_POST[content])," `id` ='$id'")){
  		   echo "修改成功<br/>";
	  }else{
			   echo "修改失败<br/>";
		}
echo "<a href=\"admin.php?action=url&\">返回域名管理</a><br/>";
}else if($act=='tj'){
echo <<<end
<div class="admin">添加域名<br/></div>
<form method="POST" action="admin.php?action=url&act=tjok">
<b>域名</b>:<input class="text" type="text" name="url" value="$row[url]" /></br>
<b>地址</b>:<input class="text" type="text" name="content" value="$row[content]" /></br>
<input class="submit" type="submit" name="adminpost" value="添加域名"/>
</form>
<div class="admin_a">注意: 请先把你的域名绑定到ip:上，然后设置绑定的地址。<br/></div>
end;
echo "<a href=\"admin.php?action=url&\">返回域名管理</a><br/>";
}else if($act=='tjok'){
		 if(!$_POST[adminpost]){
	      echo"提交出错<br/>";
	  }elseif($db->insert('url',array('id' => 'NULL','type' => '0','url' => $_POST[url],'fwsl' => '0','content' => $_POST[content]))){
  		  echo "添加成功<br/>";
	  }else{
			  echo "添加失败<br/>";
		}
echo "<a href=\"admin.php?action=url&\">返回域名管理</a><br/>";
}else if($act=='sc'){
   $db->delete('url'," `id` = '$id'");
	 echo "删除成功<br/>";
   echo "正在自动返回.......<br/><a href=\"admin.php?action=url\">请手动返回</a><br/><meta http-equiv=refresh content='3;url=admin.php?action=url'>";
}else{
echo  <<<end
<div class="admin">
域名绑定
</div><a href="admin.php?action=url&act=tj">添加域名</a>
end;
$num_count=$db->num_rows('url',"",'id');
$list_num ="10";
$num_start=page_num($list_num,$num_count);
$sql_bbs  =$db->query('url'," ORDER BY `id` DESC LIMIT ".$num_start." , ".$list_num." ",'');
while($row=mysql_fetch_array($sql_bbs)){
	if($row[type] == '1'){
		 $type='开启';
	}else{	
		 $type='关闭';
	}
	echo"<div class=\"admin_a\"><b>$row[url]</b>(访问:$row[fwsl]) <font color=#ff0000>$type</font>- <a href=\"admin.php?action=url&act=xg&id=$row[id]\">管理</a></div>";
}
echo $page=page_link($list_num,$num_count);
}
?>